package com.fanyouzhao.ehome.web.servlet.adminLimit; /**
 * @Author: fanyouzhao
 * @Date: 19:26 2021/5/12
 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(name = "AdminAddCpServlet", value = "/addCp")
public class AdminAddCpServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession(false);
        if (session!=null){
            //内部转发到主页上
            request.getRequestDispatcher("/WEB-INF/adminHtml/addCp.html").forward(request,response);
        }else{
            //没有session数据，重定向到登录页面
            response.sendRedirect("/adminLogin.html");
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
